-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Support closing keywords with URL references #36221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously, closing keywords (closes, fixes, etc.) only worked with short references like `closes go-gitea#123` or `closes org/repo#123`. This commit adds support for closing keywords with full URL references in markdown links, such as: - `Closes [this issue](https://gitea.io/user/repo/issues/123)` - `Fixes [go-gitea#456](https://gitea.io/org/project/issues/456)` The fix works by: 1. Passing the original content to findAllIssueReferencesBytes 2. When processing URL links, finding the URL position in original content 3. For markdown links [text](url), finding the opening bracket position 4. Using that position to detect closing keywords before the link Fixes go-gitea#27549
|
Could you also add test cases for bare URL? I'm pretty sure they already work, but good add more tests: |
Added test coverage for bare URLs with closing keywords: - Fixes https://... - Fixes: https://... - Closes https://... - Closes: https://... As suggested by @silverwind
|
@silverwind Added test cases for bare URLs with closing keywords. All tests passing. |
|
When idx is 0, it means the URL is at the very beginning of the content. In that case, there's nothing before it where a closing keyword like "Closes" or "Fixes" could exist. The findActionKeywords function looks at content[:start], so if start is 0, it searches an empty slice and returns XRefActionNone anyway. I can change it to idx >= 0 if you prefer - the result would be the same but maybe clearer to read. Let me know. |
|
/test-all |
* giteaofficial/main: [skip ci] Updated translations via Crowdin Use gitrepo's push function (go-gitea#36245) Support closing keywords with URL references (go-gitea#36221) Add an option to automatically verify SSH keys from LDAP (go-gitea#35927) remove nolint (go-gitea#36252) Use the requested host for LFS links (go-gitea#36242)
Summary
This PR adds support for closing keywords (
closes,fixes,reopens, etc.) with full URL references in markdown links.Before:
closes #123✅ workscloses org/repo#123✅ worksCloses [this issue](https://gitea.io/user/repo/issues/123)❌ didn't workFixes [#456](https://gitea.io/org/project/issues/456)❌ didn't workAfter:
All of the above now work correctly.
Problem
When users reference issues using full URLs in markdown links (e.g.,
Closes [this issue](https://gitea.io/user/repo/issues/123)), the closing keywords were not detected. This was because the URL processing code explicitly stated:// Note: closing/reopening keywords not supported with URLsBoth methods of writing the reference render the same in the UI, so users expected the closing keywords to behave the same.
Solution
The fix works by:
findAllIssueReferencesBytes[text](url), finding the opening bracket[positionTesting
Added test cases for:
Closes [this issue](url)- single URL with closing keywordThis fixes [#456](url)- keyword in middle of textReopens [PR](url)- reopen keyword with pull request URLAll existing tests continue to pass.
Fixes #27549